package com.yjd.pub.fundservice.service;

import com.yjd.comm.annotation.Cacheable;
import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.comm.fundservice.model.FundChannelModel;
import com.yjd.comm.fundservice.service.IFundChannelService;
import com.yjd.comm.util.FrameUtil;
import com.yjd.pub.fundservice.dao.IFundChannelDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <b>description</b>：资金渠道业务实现<br>
 * <b>time</b>：2018-01-25 17:14:39 <br>
 * <b>author</b>：  yangchangyan@yijiedai.com
 */
@Service("fundChannelService")
public class FundChannelServiceImpl extends BaseServiceImpl implements IFundChannelService {

	@Resource
	private IFundChannelDao fundChannelDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.fundChannelDao;
	}

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public FundChannelModel insert(FundChannelModel model) throws Exception {
		return this.fundChannelDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(FundChannelModel model) throws Exception {
		return this.fundChannelDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param fund_channel
	 * @return
	 * @throws Exception
	 */
	public int delete(long fund_channel) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("fund_channel", fund_channel);
		return this.fundChannelDao.deleteModel(paramMap, true);
	}

	@Cacheable
    @Override
    public List<FundChannelModel> queryAllFundChannel() throws Exception {
        return fundChannelDao.getModelList(FrameUtil.newHashMap("fund_channel_ge", "0"), false);
    }

}
